import 'package:app/core/rtc/base/session_type.dart';
import 'package:app/global_widgets/item_tile.dart';
import 'package:app/routes/my_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'logic.dart';

class FriendPage extends StatelessWidget {
  final logic = Get.put(FriendLogic());

  @override
  Widget build(BuildContext context) {
    // var friendList = state.rtc;
    // print('${friendList.length}');
    return GetBuilder<FriendLogic>(
      builder: (logic) {
        return Container(
          child: ListView.builder(
            itemBuilder: (_, index) {
              return GestureDetector(
                child: Container(
                  child: ItemTile(
                    logic.state.friends[index].picurl,
                    logic.state.friends[index].friend_name,
                    subTitle: logic.state.friends[index].remark,
                    // logic.state.rtc[index].signature,
                  ),
                  decoration: BoxDecoration(
                      border: Border(
                          bottom: BorderSide(
                    width: 1,
                    color: Color(0xffe5e5e5),
                  ))),
                ),
                onTap: () {
                  Get.toNamed(RouteConfig.CHAT, arguments: {
                    "phone": logic.state.friends[index].phone,
                    "type": SessionType.MSG,
                    "name": logic.state.friends[index].remark ??
                        logic.state.friends[index].friend_name
                  });
                },
              );
            },
            itemCount: logic.state.friends.length,
          ),
        );
      },
    );
  }
}
